import React, { Component } from 'react';
import memoryUtils from '@/utils/memoryUtils';
import { PageLoading } from '@ant-design/pro-layout';
import withRouter from 'umi/withRouter';

class index extends Component {
  render() {
    const { location } = this.props;
    const path = location.pathname.split('/');
    const handle = path[path.length-1];
    const url = memoryUtils.subSystemHandleToUrlMap[handle];
    if(url && url.startsWith('redirect:')) {
      window.location.href = url.replace('redirect:', '')
      return <PageLoading />;
    }
    return (
      <iframe src={url}
              width='100%'
              height='100%'
              frameBorder='0'
              allowTransparency='true'
              scrolling='no'>
      </iframe>
    );
  }
}

export default withRouter(index);
